using Microsoft.AspNetCore.Mvc;
using ZR.Admin.WebApi.Filters;
using ZR.Model.Dto.Business.ProductionControl;
using ZR.Model.Models.ProductionControl;
using ZR.Service.IService.ProductionControl;

//创建时间：2024-11-04
namespace ZR.Admin.WebApi.Controllers
{
    /// <summary>
    /// 钎焊
    /// </summary>
    [Verify]
    [Route("business/DcBrazingloading")]
    [ApiExplorerSettings(GroupName = "business")]
    public class DcBrazingloadingController : BaseController
    {
        /// <summary>
        /// 钎焊接口
        /// </summary>
        private readonly IDcBrazingloadingService _DcBrazingloadingService;

        public DcBrazingloadingController(IDcBrazingloadingService DcBrazingloadingService)
        {
            _DcBrazingloadingService = DcBrazingloadingService;
        }

        /// <summary>
        /// 查询钎焊列表
        /// </summary>
        /// <param name="parm"></param>
        /// <returns></returns>
        [HttpGet("list")]
        [ActionPermissionFilter(Permission = "dcbrazingloading:list")]
        public IActionResult QueryDcBrazingloading([FromQuery] DcBrazingloadingQueryDto parm)
        {
            var response = _DcBrazingloadingService.GetList(parm);
            return SUCCESS(response);
        }


        /// <summary>
        /// 查询钎焊详情
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpGet("{Id}")]
        [ActionPermissionFilter(Permission = "dcbrazingloading:query")]
        public IActionResult GetDcBrazingloading(long Id)
        {
            var response = _DcBrazingloadingService.GetInfo(Id);
            
            var info = response.Adapt<DcBrazingloadingDto>();
            return SUCCESS(info);
        }

        /// <summary>
        /// 添加钎焊
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [ActionPermissionFilter(Permission = "dcbrazingloading:add")]
        [Log(Title = "钎焊", BusinessType = BusinessType.INSERT)]
        public IActionResult AddDcBrazingloading([FromBody] DcBrazingloadingDto parm)
        {
            var modal = parm.Adapt<DcBrazingloading>().ToCreate(HttpContext);

            var response = _DcBrazingloadingService.AddDcBrazingloading(modal);

            return SUCCESS(response);
        }

        /// <summary>
        /// 更新钎焊
        /// </summary>
        /// <returns></returns>
        [HttpPut]
        [ActionPermissionFilter(Permission = "dcbrazingloading:edit")]
        [Log(Title = "钎焊", BusinessType = BusinessType.UPDATE)]
        public IActionResult UpdateDcBrazingloading([FromBody] DcBrazingloadingDto parm)
        {
            var modal = parm.Adapt<DcBrazingloading>().ToUpdate(HttpContext);
            var response = _DcBrazingloadingService.UpdateDcBrazingloading(modal);

            return ToResponse(response);
        }

        /// <summary>
        /// 删除钎焊
        /// </summary>
        /// <returns></returns>
        [HttpDelete("delete/{ids}")]
        [ActionPermissionFilter(Permission = "dcbrazingloading:delete")]
        [Log(Title = "钎焊", BusinessType = BusinessType.DELETE)]
        public IActionResult DeleteDcBrazingloading([FromRoute]string ids)
        {
            var idArr = Tools.SplitAndConvert<long>(ids);

            return ToResponse(_DcBrazingloadingService.Delete(idArr));
        }

    }
}